home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4545 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.5 KB  |  61 lines

  1. Path: news.compuserve.com!newsmaster
  2. From: Mike Davies <100717.2065@compuserve.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Borland Turbo C++
  5. Date: Tue, 30 Jan 1996 22:32:16 -0800
  6. Organization: CompuServe Incorporated
  7. Message-ID: <310F0CF0.23E1@compuserve.com>
  8. NNTP-Posting-Host: dd79-010.compuserve.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0b6a (Win16; I)
  13.  
  14. Help!
  15.  
  16. I am running Borland Turbo C++ 3.1 for Windows and am having trouble with the following program.
  17. It compiles without error and runs to end, but does not have the desired effect of altering the 
  18. text colour to red - all text is just printed in black.
  19.  
  20. If anyone knows what the problem may be - please contact me as this has been driving me mad for a 
  21. while now.
  22.  
  23. Thanks in advance,
  24.  
  25. Mike.
  26.  
  27. Email:    100717.2065@compuserve.com 
  28.   or    Mike_Davies@compuserve.com
  29.  
  30. /********************************************************************************************/
  31.  
  32. #include <stdio.h>
  33. #include <stdlib.h>
  34. #include <windows.h>
  35.  
  36. void main(void)
  37.     {
  38.     HDC hdcIC;
  39.     COLORREF colref;
  40.     
  41.     if((hdcIC = GetDC(NULL))==NULL)
  42.         {
  43.         strerror(errno);
  44.         exit(1);
  45.         }
  46.  
  47.     colref = GetTextColor(hdcIC);
  48.         printf("\n\ncolref = %d (black)", colref);
  49.  
  50.     SetTextColor(hdcIC, RGB(255, 0, 0));     /* sets color to red  */
  51.    
  52.     colref = GetTextColor(hdcIC);
  53.     printf("\n\ncolref = %d (red)", colref);
  54.  
  55.         ReleaseDC(NULL, hdcIC);
  56.  
  57.     exit(0);
  58.     }
  59.  
  60. /*****************************************************************************************/
  61.